using AForge.Imaging;
using AForge.Video;
using AxAXISMEDIACONTROLLib;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
namespace SilverSea.Video.Tools
{
	public class AMCPlayer : UserControl, IVideoSourcePlayer
	{
		private IVideoSource ivideoSource_0;
		private string string_0 = string.Empty;
		private TextOverlayLocation textOverlayLocation_0 = TextOverlayLocation.BottomLeft;
		private System.Drawing.Color color_0 = System.Drawing.Color.Blue;
		private System.Drawing.Color color_1 = System.Drawing.Color.Black;
		private System.Drawing.Color color_2 = System.Drawing.Color.Green;
		private int int_0 = 1;
		private System.Drawing.Rectangle[] rectangle_0;
		private VideoSourceErrorEventHandler videoSourceErrorEventHandler_0;
		private VideoWriterFinishEventHandler videoWriterFinishEventHandler_0;
		private DateTime dateTime_0 = DateTime.Now;
		private bool bool_0;
		private bool bool_1;
		private System.Timers.Timer timer_0 = new System.Timers.Timer();
		private string string_1 = string.Empty;
		private System.Timers.Timer timer_1 = new System.Timers.Timer();
		private int int_1;
		private object object_0 = new object();
		private float float_0;
		private float float_1;
		private bool bool_2;
		private int int_2 = 5;
		private string string_2 = "div4";
		private int int_3 = 30;
		public string videoFolder = string.Empty;
		private NewFrameHandler newFrameHandler_0;
		private int int_4;
		private int int_5;
		private int int_6;
		private int int_7;
		private int[] int_8 = new int[15];
		private long[] long_0 = new long[15];
		private IContainer icontainer_0;
		private Panel panel1;
		private Label labelCamera;
		private AxAxisMediaControl axAxisMediaControl;
		public event VideoSourceErrorEventHandler VideoSourceError
		{
			add
			{
				VideoSourceErrorEventHandler videoSourceErrorEventHandler = this.videoSourceErrorEventHandler_0;
				VideoSourceErrorEventHandler videoSourceErrorEventHandler2;
				do
				{
					videoSourceErrorEventHandler2 = videoSourceErrorEventHandler;
					VideoSourceErrorEventHandler value2 = (VideoSourceErrorEventHandler)Delegate.Combine(videoSourceErrorEventHandler2, value);
					videoSourceErrorEventHandler = Interlocked.CompareExchange<VideoSourceErrorEventHandler>(ref this.videoSourceErrorEventHandler_0, value2, videoSourceErrorEventHandler2);
				}
				while (videoSourceErrorEventHandler != videoSourceErrorEventHandler2);
			}
			remove
			{
				VideoSourceErrorEventHandler videoSourceErrorEventHandler = this.videoSourceErrorEventHandler_0;
				VideoSourceErrorEventHandler videoSourceErrorEventHandler2;
				do
				{
					videoSourceErrorEventHandler2 = videoSourceErrorEventHandler;
					VideoSourceErrorEventHandler value2 = (VideoSourceErrorEventHandler)Delegate.Remove(videoSourceErrorEventHandler2, value);
					videoSourceErrorEventHandler = Interlocked.CompareExchange<VideoSourceErrorEventHandler>(ref this.videoSourceErrorEventHandler_0, value2, videoSourceErrorEventHandler2);
				}
				while (videoSourceErrorEventHandler != videoSourceErrorEventHandler2);
			}
		}
		public event VideoWriterFinishEventHandler VideoWriterFinish
		{
			add
			{
				VideoWriterFinishEventHandler videoWriterFinishEventHandler = this.videoWriterFinishEventHandler_0;
				VideoWriterFinishEventHandler videoWriterFinishEventHandler2;
				do
				{
					videoWriterFinishEventHandler2 = videoWriterFinishEventHandler;
					VideoWriterFinishEventHandler value2 = (VideoWriterFinishEventHandler)Delegate.Combine(videoWriterFinishEventHandler2, value);
					videoWriterFinishEventHandler = Interlocked.CompareExchange<VideoWriterFinishEventHandler>(ref this.videoWriterFinishEventHandler_0, value2, videoWriterFinishEventHandler2);
				}
				while (videoWriterFinishEventHandler != videoWriterFinishEventHandler2);
			}
			remove
			{
				VideoWriterFinishEventHandler videoWriterFinishEventHandler = this.videoWriterFinishEventHandler_0;
				VideoWriterFinishEventHandler videoWriterFinishEventHandler2;
				do
				{
					videoWriterFinishEventHandler2 = videoWriterFinishEventHandler;
					VideoWriterFinishEventHandler value2 = (VideoWriterFinishEventHandler)Delegate.Remove(videoWriterFinishEventHandler2, value);
					videoWriterFinishEventHandler = Interlocked.CompareExchange<VideoWriterFinishEventHandler>(ref this.videoWriterFinishEventHandler_0, value2, videoWriterFinishEventHandler2);
				}
				while (videoWriterFinishEventHandler != videoWriterFinishEventHandler2);
			}
		}
		public event NewFrameHandler NewFrame
		{
			add
			{
				NewFrameHandler newFrameHandler = this.newFrameHandler_0;
				NewFrameHandler newFrameHandler2;
				do
				{
					newFrameHandler2 = newFrameHandler;
					NewFrameHandler value2 = (NewFrameHandler)Delegate.Combine(newFrameHandler2, value);
					newFrameHandler = Interlocked.CompareExchange<NewFrameHandler>(ref this.newFrameHandler_0, value2, newFrameHandler2);
				}
				while (newFrameHandler != newFrameHandler2);
			}
			remove
			{
				NewFrameHandler newFrameHandler = this.newFrameHandler_0;
				NewFrameHandler newFrameHandler2;
				do
				{
					newFrameHandler2 = newFrameHandler;
					NewFrameHandler value2 = (NewFrameHandler)Delegate.Remove(newFrameHandler2, value);
					newFrameHandler = Interlocked.CompareExchange<NewFrameHandler>(ref this.newFrameHandler_0, value2, newFrameHandler2);
				}
				while (newFrameHandler != newFrameHandler2);
			}
		}
		public IVideoSource VideoSource
		{
			get
			{
				return this.ivideoSource_0;
			}
			set
			{
				this.ivideoSource_0 = value;
			}
		}
		[DefaultValue(typeof(System.Drawing.Color), "Black")]
		public System.Drawing.Color BorderColor
		{
			get
			{
				return this.color_1;
			}
			set
			{
				this.color_1 = value;
				this.BackColor = this.color_1;
				base.Invalidate();
			}
		}
		[DefaultValue(typeof(System.Drawing.Color), "Green")]
		public System.Drawing.Color MotionRectangleColor
		{
			get
			{
				return this.color_2;
			}
			set
			{
				this.color_2 = value;
				this.method_0();
				base.Invalidate();
			}
		}
		[DefaultValue(1)]
		public int MotionRectangleLineWidth
		{
			get
			{
				return this.int_0;
			}
			set
			{
				this.int_0 = value;
				base.Invalidate();
			}
		}
		public System.Drawing.Rectangle[] MotionRectangles
		{
			get
			{
				return this.rectangle_0;
			}
			set
			{
				this.rectangle_0 = value;
			}
		}
		public string TextOverlay
		{
			get
			{
				return this.string_0;
			}
			set
			{
				this.string_0 = value;
			}
		}
		public TextOverlayLocation TextOverlayLocation
		{
			get
			{
				return this.textOverlayLocation_0;
			}
			set
			{
				this.textOverlayLocation_0 = value;
			}
		}
		public System.Drawing.Color TextOverlayColor
		{
			get
			{
				return this.color_0;
			}
			set
			{
				this.color_0 = value;
			}
		}
		public DateTime LastTimeReceivedFrame
		{
			get
			{
				return this.dateTime_0;
			}
			set
			{
				this.dateTime_0 = value;
			}
		}
		public float FPS
		{
			get
			{
				return this.float_0;
			}
		}
		public float BPS
		{
			get
			{
				return this.float_1;
			}
		}
		public bool EnableRecording
		{
			get
			{
				return this.bool_2;
			}
			set
			{
				this.bool_2 = value;
			}
		}
		public int RecordingRate
		{
			get
			{
				return this.int_2;
			}
			set
			{
				this.int_2 = value;
			}
		}
		public string RecordingCodec
		{
			get
			{
				return this.string_2;
			}
			set
			{
				this.string_2 = value;
			}
		}
		public int VideoLengthLimit
		{
			get
			{
				return this.int_3;
			}
			set
			{
				this.int_3 = value;
			}
		}
		public string VideoFolder
		{
			get
			{
				return this.videoFolder;
			}
			set
			{
				this.videoFolder = value;
			}
		}
		[Browsable(false)]
		public bool IsRunning
		{
			get
			{
				return this.axAxisMediaControl.Status == 2;
			}
		}
		public AMCPlayer()
		{
            //this.axAxisMediaControl = new AxAxisMediaControl();
            //this.axAxisMediaControl.BeginInit();
            //this.axAxisMediaControl.Dock = DockStyle.Fill;
            //this.axAxisMediaControl.Enabled = true;
            //this.axAxisMediaControl.Location = new System.Drawing.Point(0, 0);
            //this.axAxisMediaControl.MaximumSize = new System.Drawing.Size(1000, 10000);
            //this.axAxisMediaControl.Name = "axAxisMediaControl";
            //this.axAxisMediaControl.OcxState = (AxHost.State)componentResourceManager.GetObject("axAxisMediaControl.OcxState");
            //this.axAxisMediaControl.Size = new System.Drawing.Size(320, 240);
            //this.axAxisMediaControl.TabIndex = 1;
            //this.axAxisMediaControl.EndInit();
			
            this.InitializeComponent();

            //this.panel1.Controls.Add(axAxisMediaControl);

            this.axAxisMediaControl.EnableReconnect = true;
            this.axAxisMediaControl.MaintainAspectRatio = false;
            this.axAxisMediaControl.StretchToFit = true;
            this.axAxisMediaControl.EnableContextMenu = false;
            this.axAxisMediaControl.DisplayMessages = false;
            this.axAxisMediaControl.ShowStatusBar = false;
            this.axAxisMediaControl.ShowToolbar = false;
			this.axAxisMediaControl.NetworkTimeout = 15000;
			this.timer_0.Interval = 1000.0;
			this.timer_0.Elapsed += new ElapsedEventHandler(this.timer_0_Elapsed);
		}
		public System.Drawing.Bitmap GetCurrentVideoFrame()
		{
			return this.method_1();
		}
		public UnmanagedImage GetCurrentUnmanagedVideoFrame()
		{
			System.Drawing.Bitmap bitmap = this.method_1();
			if (bitmap != null)
			{
				return UnmanagedImage.FromManagedImage(bitmap);
			}
			return null;
		}
		public void Start()
		{
			try
			{
				if (this.IsRunning)
				{
					this.axAxisMediaControl.OnError -= new _IAxisMediaControlEvents_OnErrorEventHandler(this.axAxisMediaControl_OnError);
					this.axAxisMediaControl.OnNewImage -= new EventHandler(this.axAxisMediaControl_OnNewImage);
					this.axAxisMediaControl.OnDoubleClick -= new _IAxisMediaControlEvents_OnDoubleClickEventHandler(this.axAxisMediaControl_OnDoubleClick);
					this.axAxisMediaControl.Stop();
				}
				this.panel1.Location = new System.Drawing.Point(2, 2);
				this.panel1.Width = base.Width - 6;
				this.panel1.Height = base.Height - 6;
				if (this.string_0 != string.Empty)
				{
					this.labelCamera.Visible = true;
					this.ForeColor = this.color_0;
					this.labelCamera.Text = this.string_0;
					this.labelCamera.BackColor = System.Drawing.Color.Black;
					this.labelCamera.ForeColor = this.color_0;
					System.Drawing.Point location = new System.Drawing.Point(0, 0);
					if (this.textOverlayLocation_0 == TextOverlayLocation.TopLeft)
					{
						location = new System.Drawing.Point(0, 0);
					}
					else
					{
						if (this.textOverlayLocation_0 == TextOverlayLocation.TopRight)
						{
							location = new System.Drawing.Point(this.panel1.Width - this.labelCamera.Width, 0);
						}
						else
						{
							if (this.textOverlayLocation_0 == TextOverlayLocation.BottomLeft)
							{
								location = new System.Drawing.Point(0, this.panel1.Height - this.labelCamera.Height);
							}
							else
							{
								if (this.textOverlayLocation_0 == TextOverlayLocation.BottomRight)
								{
									location = new System.Drawing.Point(this.panel1.Width - this.labelCamera.Width, this.panel1.Height - this.labelCamera.Height);
								}
							}
						}
					}
					this.labelCamera.Location = location;
				}
				else
				{
					this.labelCamera.Visible = false;
				}
				this.method_0();
				this.int_7 = 0;
				this.int_6 = 0;
                this.axAxisMediaControl.MediaUsername = this.ivideoSource_0.Login;
                this.axAxisMediaControl.MediaPassword = this.ivideoSource_0.Password;
				this.axAxisMediaControl.MediaType = "mjpeg";
				this.axAxisMediaControl.MediaURL = this.ivideoSource_0.Source;
				this.axAxisMediaControl.SetReconnectionStrategy(60000, 20000, 300000, 25000, 0, 30000, true);
				this.axAxisMediaControl.OnError += new _IAxisMediaControlEvents_OnErrorEventHandler(this.axAxisMediaControl_OnError);
				this.axAxisMediaControl.OnNewImage += new EventHandler(this.axAxisMediaControl_OnNewImage);
				this.axAxisMediaControl.OnDoubleClick += new _IAxisMediaControlEvents_OnDoubleClickEventHandler(this.axAxisMediaControl_OnDoubleClick);
				this.axAxisMediaControl.Play();
				this.timer_0.Start();
			}
			catch (Exception ex)
			{
				if (this.videoSourceErrorEventHandler_0 != null)
				{
					this.videoSourceErrorEventHandler_0.Invoke(this, new VideoSourceErrorEventArgs("AMC start video source: " + ex.Message));
				}
			}
		}
		public void SignalToStop()
		{
		}
		public void Stop()
		{
			try
			{
				this.axAxisMediaControl.OnError -= new _IAxisMediaControlEvents_OnErrorEventHandler(this.axAxisMediaControl_OnError);
				this.axAxisMediaControl.OnNewImage -= new EventHandler(this.axAxisMediaControl_OnNewImage);
				this.axAxisMediaControl.OnDoubleClick -= new _IAxisMediaControlEvents_OnDoubleClickEventHandler(this.axAxisMediaControl_OnDoubleClick);
				this.axAxisMediaControl.Stop();
				this.timer_0.Stop();
			}
			catch (Exception ex)
			{
				if (this.videoSourceErrorEventHandler_0 != null)
				{
					this.videoSourceErrorEventHandler_0.Invoke(this, new VideoSourceErrorEventArgs("AMC stop video source: " + ex.Message));
				}
			}
		}
		private void method_0()
		{
			if (this.rectangle_0 != null && this.rectangle_0.Length > 0)
			{
                int width = this.ivideoSource_0.DesiredFrameSize.Width;
                int height = this.ivideoSource_0.DesiredFrameSize.Height;
				System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(0, 0, 9999, 9999);
				System.Drawing.Rectangle[] array = new System.Drawing.Rectangle[this.rectangle_0.Length];
				for (int i = 0; i < this.rectangle_0.Length; i++)
				{
					array[i] = new System.Drawing.Rectangle
					{
						X = this.rectangle_0[i].X * rectangle.Width / width,
						Y = this.rectangle_0[i].Y * rectangle.Height / height,
						Width = this.rectangle_0[i].Width * rectangle.Width / width,
						Height = this.rectangle_0[i].Height * rectangle.Height / height
					};
					int num = (int)this.color_2.B << 16 | (int)this.color_2.G << 8 | (int)this.color_2.R;
					this.axAxisMediaControl.SetUserWindow((short)i, string.Empty, array[i].X, array[i].Y, array[i].Width, array[i].Height, num, 100, 1);
				}
			}
		}
		private void axAxisMediaControl_OnNewImage(object sender, EventArgs e)
		{
			this.int_4++;
			if (this.bool_1)
			{
				this.StartRecording();
				this.bool_1 = false;
			}
		}
		private void timer_0_Elapsed(object sender, EventArgs e)
		{
			if (this.ivideoSource_0 != null)
			{
				this.int_8[this.int_6] = this.int_4;
				this.long_0[this.int_6] = (long)this.int_5;
				if (++this.int_6 >= 15)
				{
					this.int_6 = 0;
				}
				if (this.int_7 < 15)
				{
					this.int_7++;
				}
				this.float_0 = 0f;
				this.float_1 = 0f;
				for (int i = 0; i < this.int_7; i++)
				{
					this.float_0 += (float)this.int_8[i];
					this.float_1 += (float)this.long_0[i];
				}
				this.float_0 /= (float)this.int_7;
				this.float_1 /= (float)(this.int_7 * 1024);
				if (this.float_0 > 30f)
				{
					this.float_0 = 30f;
				}
				this.int_8[this.int_6] = 0;
				this.int_8[this.int_6] = 0;
				this.int_4 = 0;
				this.int_5 = 0;
			}
		}
		public void StartRecording()
		{
			if (this.bool_2 && this.videoFolder != string.Empty)
			{
				string text = this.videoFolder + "\\" + DateTime.Now.ToString("yyyyMMdd");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
				}
				this.string_1 = text + "\\" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".avi";
				this.axAxisMediaControl.StartRecordMedia(this.string_1, 8, string.Empty);
				this.bool_0 = true;
				this.int_1 = 0;
				this.timer_1.Interval = 60000.0;
				this.timer_1.Elapsed += new ElapsedEventHandler(this.timer_1_Elapsed);
				this.timer_1.Start();
			}
		}
		public void StopRecording()
		{
			this.axAxisMediaControl.StopRecordMedia();
			this.bool_0 = false;
			this.timer_1.Elapsed -= new ElapsedEventHandler(this.timer_1_Elapsed);
			this.timer_1.Stop();
			this.int_1 = 0;
			if (this.videoWriterFinishEventHandler_0 != null && File.Exists(this.string_1))
			{
				this.videoWriterFinishEventHandler_0(this, this.string_1);
			}
		}
		private void timer_1_Elapsed(object sender, EventArgs e)
		{
			try
			{
				this.int_1++;
				if (this.int_1 >= this.int_3)
				{
					this.int_1 = 0;
					this.StopRecording();
					if (this.bool_2)
					{
						this.StartRecording();
					}
				}
			}
			catch (Exception ex)
			{
				if (this.videoSourceErrorEventHandler_0 != null)
				{
					this.videoSourceErrorEventHandler_0.Invoke(this, new VideoSourceErrorEventArgs("videoLengthTimer_Elapsed: " + ex.Message));
				}
			}
		}
		private void axAxisMediaControl_OnError(object object_1, _IAxisMediaControlEvents_OnErrorEvent _IAxisMediaControlEvents_OnErrorEvent_0)
		{
			if (this.bool_0)
			{
				this.StopRecording();
				this.bool_1 = true;
			}
			if (this.videoSourceErrorEventHandler_0 != null)
			{
				this.videoSourceErrorEventHandler_0.Invoke(this, new VideoSourceErrorEventArgs("AMC on error: " + _IAxisMediaControlEvents_OnErrorEvent_0.theErrorInfo));
			}
		}
		private void axAxisMediaControl_OnDoubleClick(object object_1, _IAxisMediaControlEvents_OnDoubleClickEvent _IAxisMediaControlEvents_OnDoubleClickEvent_0)
		{
			base.OnDoubleClick(new EventArgs());
		}
		protected override void OnSizeChanged(EventArgs e)
		{
			this.panel1.Location = new System.Drawing.Point(2, 2);
			this.panel1.Width = base.Width - 6;
			this.panel1.Height = base.Height - 6;
			if (this.string_0 != string.Empty)
			{
				this.labelCamera.Visible = true;
				this.ForeColor = this.color_0;
				this.labelCamera.Text = this.string_0;
				this.labelCamera.BackColor = System.Drawing.Color.Black;
				this.labelCamera.ForeColor = this.color_0;
				System.Drawing.Point location = new System.Drawing.Point(0, 0);
				if (this.textOverlayLocation_0 == TextOverlayLocation.TopLeft)
				{
					location = new System.Drawing.Point(0, 0);
				}
				else
				{
					if (this.textOverlayLocation_0 == TextOverlayLocation.TopRight)
					{
						location = new System.Drawing.Point(this.panel1.Width - this.labelCamera.Width, 0);
					}
					else
					{
						if (this.textOverlayLocation_0 == TextOverlayLocation.BottomLeft)
						{
							location = new System.Drawing.Point(0, this.panel1.Height - this.labelCamera.Height);
						}
						else
						{
							if (this.textOverlayLocation_0 == TextOverlayLocation.BottomRight)
							{
								location = new System.Drawing.Point(this.panel1.Width - this.labelCamera.Width, this.panel1.Height - this.labelCamera.Height);
							}
						}
					}
				}
				this.labelCamera.Location = location;
			}
			else
			{
				this.labelCamera.Visible = false;
			}
			base.OnSizeChanged(e);
		}
		public void SaveCurrentVideoFrame(string path)
		{
			this.axAxisMediaControl.SaveCurrentImage(0, path);
		}
		private unsafe System.Drawing.Bitmap method_1()
		{
			object obj = null;
			int num = 0;
			//this.axAxisMediaControl.GetCurrentImage(1, ref obj, ref num);
            this.axAxisMediaControl.GetCurrentImage(1, out obj, out num);
			byte[] array = new byte[num];
			Array array2 = (Array)obj;
			array2.CopyTo(array, 0);
			IVideoSource expr_30 = this.ivideoSource_0;
            expr_30.FramesReceived = expr_30.FramesReceived + 1;
			IVideoSource expr_43 = this.ivideoSource_0;
			expr_43.BytesReceived = expr_43.BytesReceived + num;
			int num2 = 0;
			int num3 = 0;
			this.method_2(num, ref num2, ref num3);
			if (num2 > 0 && num3 > 0)
			{
				byte[] array3;
				byte* ptr;
				if ((array3 = array) != null && array3.Length != 0)
				{
                    unsafe
                    {
                        fixed (byte* bts = array3)
                        {
                            ptr = bts;
                        }
                        //ptr = array3;
                    }
				}
				else
				{
					ptr = null;
				}
				return this.method_3(new IntPtr((void*)ptr), num2, num3);
			}
			return null;
		}
		private void method_2(int int_9, ref int int_10, ref int int_11)
		{
			if (int_9 == 57640)
			{
				int_10 = 160;
				int_11 = 120;
				return;
			}
			if (int_9 == 59176)
			{
				int_10 = 176;
				int_11 = 112;
				return;
			}
			if (int_9 == 76072)
			{
				int_10 = 176;
				int_11 = 144;
				return;
			}
			if (int_9 == 82984)
			{
				int_10 = 192;
				int_11 = 144;
				return;
			}
			if (int_9 == 172840)
			{
				int_10 = 320;
				int_11 = 180;
				return;
			}
			if (int_9 == 230440)
			{
				int_10 = 320;
				int_11 = 240;
				return;
			}
			if (int_9 == 253480)
			{
				int_10 = 352;
				int_11 = 240;
				return;
			}
			if (int_9 == 304168)
			{
				int_10 = 352;
				int_11 = 288;
				return;
			}
			if (int_9 == 691240)
			{
				int_10 = 640;
				int_11 = 360;
				return;
			}
			if (int_9 == 921640)
			{
				int_10 = 640;
				int_11 = 480;
				return;
			}
			if (int_9 == 1013800)
			{
				int_10 = 704;
				int_11 = 480;
				return;
			}
			if (int_9 == 1216552)
			{
				int_10 = 704;
				int_11 = 576;
				return;
			}
			if (int_9 == 1440040)
			{
				int_10 = 800;
				int_11 = 600;
				return;
			}
			if (int_9 == 2073640)
			{
				int_10 = 960;
				int_11 = 720;
				return;
			}
			if (int_9 == 2764840)
			{
				int_10 = 1280;
				int_11 = 720;
				return;
			}
			if (int_9 == 3686440)
			{
				int_10 = 1280;
				int_11 = 960;
				return;
			}
			if (int_9 == 3932200)
			{
				int_10 = 1280;
				int_11 = 1024;
				return;
			}
			if (int_9 == 6220804)
			{
				int_10 = 1920;
				int_11 = 1080;
				return;
			}
			if (int_9 == 9437224)
			{
				int_10 = 2048;
				int_11 = 1536;
				return;
			}
			int_10 = 0;
			int_11 = 0;
		}
		private System.Drawing.Bitmap method_3(IntPtr intptr_0, int int_9, int int_10)
		{
			System.Drawing.Bitmap result;
			lock (this.object_0)
			{
				if (intptr_0 == IntPtr.Zero)
				{
					throw new ApplicationException("Failed getting frame");
				}
				BITMAPINFOHEADER bITMAPINFOHEADER = (BITMAPINFOHEADER)Marshal.PtrToStructure(intptr_0, typeof(BITMAPINFOHEADER));
				System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(int_9, int_10, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
				System.Drawing.Imaging.BitmapData bitmapData = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, int_9, int_10), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
				int stride = bitmapData.Stride;
				int stride2 = bitmapData.Stride;
				if (bITMAPINFOHEADER.height > 0)
				{
					int num = bitmapData.Scan0.ToInt32() + stride2 * (int_10 - 1);
					int num2 = intptr_0.ToInt32() + Marshal.SizeOf(typeof(BITMAPINFOHEADER));
					for (int i = 0; i < int_10; i++)
					{
						Win32.memcpy(num, num2, stride);
						num -= stride2;
						num2 += stride;
					}
				}
				else
				{
					int dst = bitmapData.Scan0.ToInt32();
					int src = intptr_0.ToInt32() + Marshal.SizeOf(typeof(BITMAPINFOHEADER));
					Win32.memcpy(dst, src, stride * int_10);
				}
				bitmap.UnlockBits(bitmapData);
				result = bitmap;
			}
			return result;
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.icontainer_0 != null)
			{
				this.icontainer_0.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
            ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(AMCPlayer));
            this.panel1 = new Panel();
            this.labelCamera = new Label();
            this.axAxisMediaControl = new AxAxisMediaControl();
            this.panel1.SuspendLayout();
            this.axAxisMediaControl.BeginInit();
            base.SuspendLayout();
            this.panel1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
            this.panel1.Controls.Add(this.labelCamera);
            this.panel1.Controls.Add(this.axAxisMediaControl);
            this.panel1.Location = new System.Drawing.Point(2, 2);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(320, 240);
            this.panel1.TabIndex = 4;
            this.labelCamera.AutoSize = true;
            this.labelCamera.BackColor = System.Drawing.Color.Black;
            this.labelCamera.Font = new System.Drawing.Font("Verdana", 9.75f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
            this.labelCamera.ForeColor = System.Drawing.Color.White;
            this.labelCamera.Location = new System.Drawing.Point(0, 0);
            this.labelCamera.Name = "labelCamera";
            this.labelCamera.Size = new System.Drawing.Size(57, 16);
            this.labelCamera.TabIndex = 4;
            this.labelCamera.Text = "Camera";
            this.labelCamera.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.axAxisMediaControl.Dock = DockStyle.Fill;
            this.axAxisMediaControl.Enabled = true;
            this.axAxisMediaControl.Location = new System.Drawing.Point(0, 0);
            this.axAxisMediaControl.MaximumSize = new System.Drawing.Size(1000, 10000);
            this.axAxisMediaControl.Name = "axAxisMediaControl";
            this.axAxisMediaControl.OcxState = (AxHost.State)componentResourceManager.GetObject("axAxisMediaControl.OcxState");
            this.axAxisMediaControl.Size = new System.Drawing.Size(320, 240);
            this.axAxisMediaControl.TabIndex = 1;
            base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.BorderStyle = BorderStyle.FixedSingle;
            base.Controls.Add(this.panel1);
            base.Name = "AMCPlayer";
            base.Size = new System.Drawing.Size(324, 244);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.axAxisMediaControl.EndInit();
            base.ResumeLayout(false);
		}
	}
}
